'''
Created on 2011-09-07

@author: kacper
'''
import unittest
from dataStructs.formulaSet import Theory
from config.config import getValidParseExamplesDirs


class Test(unittest.TestCase):


    def loadTheory(self, dataBaseFile):
        kb =  getValidParseExamplesDirs() +dataBaseFile 
        th = Theory(kb)    
        return th
    
    
    def testThen3Times(self):
        th = self.loadTheory("/then3times.wn")
        res = th.isOptymistic("a", nr=5)
        self.assertTrue(res)
        self.assertRaises(StopIteration,th.isOptymistic,"w", nr=5)
        res = th.isOptymistic("b", nr=5)
        self.assertTrue(res)
        res = th.isOptymistic("d", nr=5)
        self.assertTrue(res)
        
    def testThen3timesWithUniversal(self):
        th = self.loadTheory("/then3timesWithUniversal.wn")
        res = th.isOptymistic("a", nr=5)
        self.assertTrue(res)
        res = th.isOptymistic("b", nr=5)
        self.assertTrue(res)
        res = th.isOptymistic("d", nr=5)
        self.assertTrue(res)
        
    def testRelationUniversal(self):
        th = self.loadTheory("/relationUniversal.wn")
        res = th.isOptymistic("r(a,b,b)", nr=5)
        self.assertTrue(res)
        res = th.isOptymistic("r(a,v,v)", nr=5)
        self.assertTrue(res)
        res = th.isOptymistic("r(x,v,v)", nr=5)
        self.assertTrue(res)
        
    
if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    unittest.main()